<?php 
class fileClassAction extends Action
{
	
	public function defaultAction()
	{
		
		
	}
	
	public function filesAction()
	{
		
		
	}
	
	public function dataAction()
	{
		$limit= (int)$this->get('limit','1');
		$sort = $this->get('sort');
		$dir  = $this->get('dir');
		$id   = (int)$this->get('id','0');
		$order= '`lastdt` desc';
		if($sort && $dir)$order= '`'.$sort.'` '.$dir.'';
		$where = '`platid`='.$this->adminid.'';
		if($id>0)$where.=' and `agentid`='.$id.'';
		$barr = m('file')->getlimit($where, (int)$this->get('page','1'),'*',$order, $limit);
		
		
		$rows  = $barr['rows'];
		$fobj	= m('files');
		foreach($rows as $k=>$rs){
			$rows[$k]['editci'] = $fobj->rows('`mid`='.$rs['id'].'');
		}
		
		$total = count($rows);
		$barr = array(
			'rows' => $rows,
			'totalCount'=> $barr['count'],
			'success' => true,
		);
		return $barr;
	}
	
	public function datasAction()
	{
		$limit= (int)$this->get('limit','1');
		$sort = $this->get('sort');
		$dir  = $this->get('dir');
		$id   = (int)$this->get('id','0');
		$order= '`id` desc';
		if($sort && $dir)$order= '`'.$sort.'` '.$dir.'';
		$where = '`platid`='.$this->adminid.'';
		if($id>0)$where.=' and `mid`='.$id.'';
		$barr = m('files')->getlimit($where, (int)$this->get('page','1'),'*',$order, $limit);
		
		
		$rows  = $barr['rows'];
	
		
		$total = count($rows);
		$barr = array(
			'rows' => $rows,
			'totalCount'=> $barr['count'],
			'success' => true,
		);
		return $barr;
	}
	
}